(function() {
    var _v;
    Vue.component('Login', {
        props: {

        } ,
        data: function() {
            return {
                params: {
                    user_name : '',
                    serial_number : '',
                    password: ''
                },
                msg: ''
            }
        },
        computed: {
            validLogin: function () {
                return (_v.params.user_name !== '' && _v.params.serial_number !== '' && _v.params.password !== '');
            }
        },
        methods: {
            closeModal: function() {
                console.log('close====')
                this.$emit('close')
            },
            doLogin: function() {
                HQ.ajax("/login", JSON.stringify(_v.params), function(data) {
                    _v.msg = '';
                    localStorage.setItem('user_logn','1');
                    localStorage.setItem('_token', JSON.stringify(data.data));
                    location.reload();
                }, function(data){
                    _v.msg = data.msg;
                }, "POST");
            }
        },
        created: function() {
            _v = this;
        },
        mounted: function() {
            console.log(_v)
        },
        template: '<div>\n' +
            '        <div id="bg" style="width: 100%;height: 100%;position: fixed;top: 0;left: 0"></div>\n' +
            '        <div class="index-popup login-popup radius-4" style="width: 390px;position: fixed;top: 40%;left: 40%">\n' +
            '            <div class="index-popup-cont radius-4">\n' +
            '                <div class="nav-menu-pop nav-menu-pop-login J_nav_menu_popup_login radius-4">\n' +
            '                    <div class="account-main">\n' +
            '                        <div class="account-title f20 rel">\n' +
            '                            <ul class="account-tab clearfix m0auto" id="J_popup_tab">\n' +
            '                                <li class="fl pointer t-333 current">Login</li>\n' +
            '                            </ul>\n' +
            '                            <a class="db abs icon_close J_close_popup_login_pop bg_size" href="javascript:;" @click="closeModal" title="关闭"></a>\n' +
            '                        </div>\n' +
            '                        <div class="account-cont bg-fff">\n' +
            '                            <div class="J_popup_tab_cont">\n' +
            '                                <input type="hidden" name="type" value="mobile">\n' +
            '                                <div class="account-form-l">\n' +
            '                                    <input class="account-f-l-txt radius-4 f14 icon_login_code" type="text" placeholder="企业编号" v-model="params.serial_number" style="color: rgb(51, 51, 51);">\n' +
            '                                </div>\n' +
            '                                <div class="account-form-l">\n' +
            '                                    <input class="account-f-l-txt radius-4 f14 icon_login_account" type="text" placeholder="账号" v-model="params.user_name" style="color: rgb(51, 51, 51);">\n' +
            '                                </div>\n' +
            '                                <div class="account-form-l">\n' +
            '                                    <input type="text" value="" name="password" autocomplete="off" class="account-f-l-txt radius-4 f14 hide icon_login_paw" style="color:#333;">\n' +
            '                                    <input class="account-f-l-txt radius-4 f14 icon_login_paw" type="text" placeholder="密码" v-model="params.password" >\n' +
            '                                </div>\n' +
            '                                <div class="account-error-msg f12 tal" style="visibility:unset" v-show="msg">{{msg}}</div>\n' +
            '                                <div class="account-form-l mb6">\n' +
            '                                    <button class="t-fff tac bg-49f bg-5da7ff-hover radius-4 f16 pointer account-btn" :disabled="!validLogin" type="button" @click="doLogin">登录</button>\n' +
            '                                    <input type="hidden" value="">\n' +
            '                                </div>\n' +
            '                                <div class="account-form-l-t clearfix">\n' +
            '                                    <div class="account-form-l-t-forget fr f12">\n' +
            '                                        <span class="t-ec">|</span>\n' +
            '                                        <a class="db fl tdu-hover J_go_register" href="/register.html">免费注册</a>\n' +
            '                                    </div>\n' +
            '                                </div>\n' +
            '                                <p></p>\n' +
            '                            </div>\n' +
            '                        </div>\n' +
            '                    </div>\n' +
            '                </div>\n' +
            '            </div>\n' +
            '        </div>\n' +
            '    </div>'
    })
})()
